#include <stdio.h>
#include <math.h>

int main(void) {
    int n = 0;
    while(1) {
        char c = getchar();
        getchar();
        if (c == '#') {
            break;
        }
        printf("case %d:\n", ++n);
        int indent = 0;
        for (char center = c; center >= 'A'; center--) {
            for (int i = 0; i < indent; i++) {
                putchar(' ');
            }
            for (char i = 'A'; i <= center; i++) {
                putchar(i);
            }
            for (char i = center - 1; i >= 'A'; i--) {
                putchar(i);
            }
            indent++;
            putchar('\n');
        }
    }
    return 0;
}
